package frame.laxcen.test;

import frame.laxcen.request.Request_0010_11;
import frame.laxcen.response.Response_0010_11;
import frame.laxcen.util.FrameUtil;
import tcpclient.v2.RFIDClient;
import frame.util.Ref;

import java.io.IOException;
import java.net.InetSocketAddress;

public class RFIDClient_Write_Match_Tid {

    public static void main(String[] args) throws IOException {

        RFIDClient client = new RFIDClient(1 << 20, 1024);

        if(client.tryConnect(new InetSocketAddress("192.168.1.116", 9090), 3000)) {

            System.out.println("连接成功！");

            Request_0010_11.RequestTemplate template = new Request_0010_11.RequestTemplate();

            template.useAntenna_1();

            template.standerSingleWrite("FF00AA00ZZ001100");

            template.matchTid("e2801105200076dbbd1a0919");

            if(client.trySend(new Request_0010_11(template), 3000)) {

                System.out.println("写标签 ...");

                Ref<Response_0010_11> ref = client.waitForResponse(6000, Response_0010_11.class);

                if(ref.isPresent()) {

                    System.out.println("获取到反馈信息！");

                    FrameUtil.printResponse(ref.get());
                }

                System.out.println("操作结束");
            }
        }

        if(client.tryClose()) System.out.println("成功关闭连接！"); else System.out.println("没有成功关闭！");
    }
}
